/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.actions.user;

import com.myapp.entity.Uzer;
import com.myweb.WebAction;
import com.myweb.WebException;
import com.myweb.WebRequest;
import com.myweb.WebResponse;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

/**
 *
 * @author DTIT
 */
public class DeleteUser implements WebAction {

  private Long id;

  @Override
  public void prepare(WebRequest request) throws WebException {
    id = request.getLongNN("id");
  }

  @Override
    public EntityManager process(WebRequest req, WebResponse res, EntityManager em) throws Exception {
    Uzer user = em.getReference(Uzer.class, id);
    user.setDeleted(true);
    res.setMessage("Deleted user");
    res.setResult(user);
    return em;
  }
}
